package com.zhuoyue.zhtj;

import com.eit.eitsite.common.utils.HttpUtils;

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.URLEncoder;

/**
 * Created by kaygreen on 2017/9/25.
 */
public class ServerThread extends Thread {
    private Socket socket=null;
    public ServerThread(Socket socket){
        this.socket=socket;
    }

    @Override
    public void run() {
        try {
            InputStream is=socket.getInputStream();
            ObjectInputStream ois=new ObjectInputStream(is);
            Object item=ois.readObject();
            HttpUtils.httpStrGet("http://www.joyue-tech.com/szptApp/a/zhtj/kckqjl/saveRecord?str="+ URLEncoder.encode(item.toString(),"utf-8"));
            System.out.println(item.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        try {
            ServerSocket serverSocket =new ServerSocket(10096);
            while(true){
                Socket socket=serverSocket.accept();
                ServerThread st=new ServerThread(socket);
                st.start();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
